package cn.edu.xmu.oomall.aftersales.model.bo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

/**
 * @author Jiawei Zheng
 * @date 2021-12-11
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class AfterSale {
    public enum AfterSaleState {
        NEW((byte)0, "新建态"),
        WAIT_CUSTOMER_POST((byte)1, "待买家发货"),
        CUSTOMER_POSTED((byte)2, "买家已发货"),
        WAIT_REFUND((byte)3, "待退款"),
        WAIT_SHOP_POST((byte)4, "待店家发货"),
        SHOP_POSTED((byte)5, "店家已发货"),
        FINISHED((byte)6, "已结束"),
        CANCELED((byte)7, "已取消"),
        WAIT_PAY((byte)8, "待支付");

        private static final Map<Byte, AfterSaleState> stateMap;
        static { //由类加载机制，静态块初始加载对应的枚举属性到map中，而不用每次取属性时，遍历一次所有枚举值
            stateMap = new HashMap();
            for (AfterSaleState enum1 : values()) {
                stateMap.put(enum1.code, enum1);
            }
        }
        private byte code;
        private String description;

        AfterSaleState(byte code, String description) {
            this.code = code;
            this.description = description;
        }

        public static AfterSaleState getTypeByCode(Byte code) {
            return stateMap.get(code);
        }

        public Byte getCode() {
            return code;
        }

        public String getDescription() {
            return description;
        }
    }

    Long id;

    Long orderId;

    Long orderItemId;

    Long customerId;

    Long shopId;

    String serviceSn;

    Byte type;

    String reason;

    String conclusion;

    Long price;

    Long quantity;

    Long regionId;

    String detail;

    String consignee;

    String mobile;

    String customerLogSn;

    String shopLogSn;

    AfterSaleState state;

    Byte beDeleted;

    Long creatorId;

    String creatorName;

    Long modifierId;

    String modifierName;

    LocalDateTime gmtCreate;

    LocalDateTime gmtModified;
}
